package demo.icanci.proxy.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author icanci
 * @date Created in 2021/03/03 21:17
 * @version 1.0
 */
public class AlipayInvocationHandler implements InvocationHandler {
    private Object targetObject;

    public AlipayInvocationHandler(Object targetObject) {
        this.targetObject = targetObject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        beforePay();
        Object invoke = method.invoke(targetObject, args);
        afterPay();
        return invoke;
    }

    private void afterPay() {
        System.out.println("AlipayInvocationHandler.afterPay  取钱");
    }

    private void beforePay() {
        System.out.println("AlipayInvocationHandler.beforePay 付钱");
    }
}
